package view;

import javax.swing.text.*;

public class TextDoc extends PlainDocument {

	private static final long serialVersionUID = 1L;
	private int maxLength;

	public TextDoc(int maxLength) {
		this.maxLength = maxLength;
	}

	@Override
	public void insertString(int offs, String str, AttributeSet a)
			throws BadLocationException {
		if (str.length() == 0)
			return;
		if (getLength() + str.length() < maxLength) {
			super.insertString(offs, str, a);
		}
	}
}